import React,{useState} from "react";
import {Button} from 'antd';
import {flushSync} from 'react-dom';
function Demo2(props){
    console.log('我爱公主');
    let [x,setX] = useState(0),
        [y,setY] = useState(0),
        [z,setZ] = useState(0);
    const handler = ()=>{
        
        flushSync(()=>{ // 遇到 flushSync 会立即刷新更新队列
            setX(x+1);
            setY(y+1);
        })
        setZ(z+1);
    }
    return <div>
        <span>X:{x}</span>
        <span>Y:{y}</span>
        <span>Z:{z}</span>
        <Button onClick={handler}>点我加一</Button>
    </div>
}
export default Demo2